home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="UTF-8"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
- <!-- Order XML nodes on a precedence -->
-
- <!-- define a precedence order variable -->
- <xsl:variable name="lifeboat-precedence" select="'|*|Man|Boy|Woman|Girl'"/>
- <!-- Note: the precedence is specified in reverse order! -->
-
- <xsl:template match="/">
- <html>
- <head>
- <title>Women and Children to the life boats first!</title>
- </head>
- <body>
- <h3>Women and Children to the life boats first!</h3>
- <table border="1">
- <tr>
- <th>Priority</th>
- <th>Passenger name</th>
- <th>Age/Gender</th>
- <th>No.</th>
- </tr>
- <xsl:apply-templates select="passengers/passenger">
- <xsl:sort select="string-length(substring-before($lifeboat-precedence,concat('|',@age_gender)))" data-type="number" order="descending"/>
- </xsl:apply-templates>
- </table>
- </body>
- </html>
- </xsl:template>
-
- <xsl:template match="passenger">
- <tr>
- <td align="right"><xsl:value-of select="string-length(substring-before($lifeboat-precedence,concat('|',@age_gender)))"/></td>
- <td><xsl:value-of select="."/></td>
- <td><xsl:value-of select="@age_gender"/></td>
- <td align="right"><xsl:value-of select="count(preceding-sibling::passenger)+1"/></td>
- </tr>
- </xsl:template>
- </xsl:stylesheet>